** This do file recreates the results summarized in Figure 4 of the paper

* The code uses aggregate census data calculated from the IPUMS International 
* Census Microdata Repository at https://international.ipums.org/international/

* set directory to folder with replication data
cd "~\Replication\"

** census-panel comparisons
use sample_panel_comparison_aggregates.dta, clear

graph bar census_pct panel_pct if country == "Chile", over(edr, relabel(3 `""Post-""Secondary""')) ///
legend(label(1 "Population") label(2 "Panel") pos(6) row(1)) ///
scheme(plotplain) ytitle("Percent") scale(1) title("Chile", size(small)) ///
ylab(0 "0" 20 "20" 40 "40" 60 "60") saving(cl_edu_panel, replace) 
*graph export cl_edu_comparison_panel.png, as(png) width(1000) replace

graph bar census_pct panel_pct if country == "Colombia", over(edr, relabel(3 `""Post-""Secondary""')) ///
legend(label(1 "Population") label(2 "Panel") pos(6) row(1)) ///
scheme(plotplain) ytitle("Percent") scale(1) title("Colombia", size(small)) ///
ylab(0 "0" 20 "20" 40 "40" 60 "60") saving(co_edu_panel, replace)
*graph export co_edu_comparison_panel.png, as(png) width(1000) replace

graph bar census_pct panel_pct if country == "Peru", over(edr, relabel(3 `""Post-""Secondary""')) ///
legend(label(1 "Population") label(2 "Panel") pos(6) row(1)) ///
scheme(plotplain) ytitle("Percent") scale(1) title("Peru", size(small)) ///
ylab(0 "0" 20 "20" 40 "40" 60 "60") saving(pe_edu_panel, replace)
*graph export pe_edu_comparison_panel.png, as(png) width(1000) replace

graph bar census_pct panel_pct if country == "Brazil", over(edr, relabel(3 `""Post-""Secondary""')) ///
legend(label(1 "Population") label(2 "Panel") pos(6) row(1)) ///
scheme(plotplain) ytitle("Percent") scale(1) title("Brazil", size(small)) saving(br_edu_panel, replace)
*graph export br_edu_comparison_panel.png, as(png) width(1000) replace

graph bar census_pct panel_pct if country == "Argentina", over(edr, relabel(3 `""Post-""Secondary""')) ///
legend(label(1 "Population") label(2 "Panel") pos(6) row(1)) ///
scheme(plotplain) ytitle("Percent") scale(1) title("Argentina", size(small)) saving(ar_edu_panel, replace)
*graph export ar_edu_comparison_panel.png, as(png) width(1000) replace

graph bar census_pct panel_pct if country == "Mexico", over(edr, relabel(3 `""Post-""Secondary""')) ///
legend(label(1 "Population") label(2 "Panel") pos(6) row(1)) ///
scheme(plotplain) ytitle("Percent") scale(1) title("Mexico", size(small)) saving(mx_edu_panel, replace)
*graph export mx_edu_comparison_panel.png, as(png) width(1000) replace

* combine
graph combine ar_edu_panel.gph br_edu_panel.gph cl_edu_panel.gph co_edu_panel.gph mx_edu_panel.gph pe_edu_panel.gph, row(3) scheme(plotplain) ysize(7) xsize(4.5)
